package com.guigu.lc.controller;

import com.guigu.common.pojo.*;
import com.guigu.common.vo.SearchVo;
import com.guigu.lc.service.materialService;
import com.guigu.lc.view.desginmaterview;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * 产品物料设计的，审核，查询，变更的Controller
 */
@Controller
@RequestMapping("/lc")
@ResponseBody()
public class materialController {

    @Resource
    private materialService service;

    /**
     * 制定
     * @param searchVo
     * @return
     */
    @RequestMapping("/querymaterialldata")
    public SearchVo<MDesignProcedure> querymaterialldata(SearchVo<MDesignProcedure> searchVo){
     return this.service.querymaterialldata(searchVo);
    }

    /**
     * 审核查询
     * @param searchVo
     * @return
     */
    @RequestMapping("/querycheckmaterialinfo")
    public SearchVo<MDesignProcedure> querycheckmaterialinfo(SearchVo<MDesignProcedure> searchVo){
        return this.service.querycheckmaterService(searchVo);
    }

    /**
     * 查询
     * @param searchVo
     * @return
     */
    @RequestMapping("/querymaterdesyall")
    public SearchVo<MDesignProcedure> querymaterdesyall(SearchVo<MDesignProcedure> searchVo){
        return this.service.queryallsymaterService(searchVo);
    }

    /**
     * 变更查询
     * @param searchVo
     * @return
     */
    @RequestMapping("/querychangematertrue")
    public SearchVo<MDesignProcedure> querychangematertrue(SearchVo<MDesignProcedure> searchVo){
       return this.service.querycallmatertrueService(searchVo);
    }

    /**
     * 查询审核通过的产物料组成，if不为空就可以设计否则就不能设计
     * @param id
     * @return
     */
    @RequestMapping("/shejichax")
    public DesignModule shejichax(String id){
        return this.service.queryByproductidService(id);
    }

    /**
     * 物料组成设计完成根据物料组成id查询物料组成明细
     * @param id
     * @return
     */
    @RequestMapping("/querywuliaocuchen")
    public List<DModuleDetails> querywuliaocuchen(int id){
        return this.service.queryByidproductidService(id);
    }

    /**
     * 查询工序物料设计是否已经设计：
     * @param id
     * @return
     */
    @RequestMapping("/queryBymoduletrue")
    public List<MDesignProcedureModule> queryBymoduletrue(int id){
        return this.service.queryByparentidService(id);

    }

    /**
     * 设计提交
     */
    @RequestMapping("/shejitijiao")
    public int shejitijiao(@RequestBody() desginmaterview desginmaterview){
        System.out.println(desginmaterview);
        this.service.updateshejiService(desginmaterview);
        return 1;
    }

    /**
     * 重新设计
     */
    @RequestMapping("/updategxmxfalse")
    public int updategxmxfalse(@RequestBody() desginmaterview desginmaterview){
        this.service.updatecxshejiService(desginmaterview);
        return 1;
    }

    /**
     * 查询是否所有工序都是显示已设计
     * @param id
     * @return
     */
    @RequestMapping("/checkgxshifousheji")
    public int checkgxshifousheji(int id){
        return this.service.checkgxshifoushejiService(id);
    }

    /**
     * 查询物料小计
     */
    @RequestMapping("/ssmx")
    public  List<MDesignProcedureDetails> ssmx(int id){
        return this.service.querywuiaoxiaojiService(id);
    }

    @RequestMapping("/xiugaigxshejiyishejiwuliao")
    public int xiugaigxshejiyishejiwuliao(@RequestBody() MDesignProcedure mdesignProcedure){
    this.service.updatewuliaozcbdshService(mdesignProcedure);
        return 1;
    }

    /**
     * 物料设计审核不通过
     * @param desginmaterview
     * @return
     */
    @RequestMapping("/wuliaoshenghenofalse")
    public int wuliaoshenghenofalse(@RequestBody() desginmaterview desginmaterview){
        this.service.updateshenghefalse(desginmaterview);
        return 1;
    }

    @RequestMapping("/wuliaoshengheokok")
    public int wuliaoshengheokok(@RequestBody() desginmaterview desginmaterview){
        this.service.updateshengheokkService(desginmaterview);
        return 1;
    }

    /**
     * 查询等于0
     * @param id
     * @return
     */
    @RequestMapping("/queryamout0")
    public int queryamout0(int id){
        return this.service.queryamout0Service(id);
    }

    /**
     * 点击变更删除物料明细表，把数量加回去
     *
     */
    @RequestMapping("/gxmxchange")
    public int gxmxchange (@RequestBody() desginmaterview desginmaterview){
        System.out.println(desginmaterview+"dadasdasda");
        this.service.deleteandupdatechangestartService(desginmaterview);
        return 1;
    }

    @RequestMapping("/selectwuliaozucmx")
    public List<DModuleDetails> selectwuliaozucmx(String cpbh){
        return this.service.selectwuliaozcmxService(cpbh);
    }

    /**
     * 变更提交
     */
    @RequestMapping("/biangengtijiaoController")
    public int biangengtijiaoController(@RequestBody() desginmaterview desginmaterview){
        System.out.println(desginmaterview);
        this.service.biangengtijiaoService(desginmaterview);
        return 1;
    }

    @RequestMapping("/chaxdengyu0")
    public int chaxdengyu0(String id){
        return this.service.chaxdengyu0(id);
    }

    //重新提交
    @RequestMapping("/cxtxbgdas")
    public int cxtxbgdas(String descid){
        this.service.cxtxbgdasService(descid);
        return 1;
    }
}
